package com.ykq.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ykq.dao.RoleMapper;
import com.ykq.entity.Role;
import com.ykq.service.RoleService;
import com.ykq.vo.R;
import com.ykq.vo.RoleSearchVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @program: qy174-mrcai
 * @description:
 * @author: 闫克起
 * @create: 2024-06-06 08:48
 **/
@Service
public class RoleServiceImpl implements RoleService {

    @Autowired
    private RoleMapper roleMapper;

    public R findByConditionPage(Integer current, Integer pageSize, RoleSearchVo roleSearchVo) {
        //开启分页
        PageHelper.startPage(current,pageSize);
        //调用dao功能
        List<Role> roles = roleMapper.selectByConditionPage(roleSearchVo);
        //封装到PageInfo中
        PageInfo<Role> pageInfo=new PageInfo<Role>(roles);
        return new R(2000,"查询角色成功",pageInfo);
    }

    public R updateStatus(Long id, Integer status) {
        Role role=new Role();
        role.setId(id);
        role.setStatus(status+"");
        int i = roleMapper.updateByPrimaryKeySelective(role);
        return i>0?new R(2000,"更新状态成功",null):new R(5000,"更新失败",null);
    }
}




















